package com.demo.unittest.springweb.service;

import com.demo.unittest.springweb.bean.User;
import com.demo.unittest.springweb.dao.UserDAO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author tzp
 * @since 2018/4/28
 */
@Service
public class UserService {
    private Logger logger = LoggerFactory.getLogger(UserService.class);
    @Autowired
    private UserDAO userDAO;

    public User authenticateUser(String name, String password) {
        User user = userDAO.getUserByPassword(name, password);
        return user;
    }

    public User saveUser(String name, String password) {
        User user = new User();
        user.setName(name);
        user.setPassword(password);
        userDAO.insertUser(user);
        return user;
    }

}
